CREATE OR REPLACE VIEW vw_employee_workload_salary AS
SELECT
    e.id AS employee_id,
    p.first_name,
    p.last_name,
    p.email,
    e.date_of_hire,

    s.store_id,
    s.name AS store_name,

    w.week,
    w.total_week,
    w.working_hours,
    w.wage,
    w.pay_method

FROM employees e
JOIN personal p
    ON p.id = e.id
JOIN works_in_store wis
    ON wis.id = e.id
JOIN store s
    ON s.store_id = wis.store_id
LEFT JOIN worked w
    ON w.id = e.id
    AND w.store_id = wis.store_id;
